#encoding=utf8
'''
Created on 2012-10-17

@author: Administrator
'''
from Processor import Processor
from pub import Func, UserDict;
from pub.Config import Config;
from models import UserModel;

class UFCClass(Processor):
    '''
    指令：UFC(user friend chat) 
    备注：玩家之间聊天
    格式：c-s:Cmd#cmdID#userIDFrom#userIDTo#infos
     s-c:Cmd#cmdID#userIDFrom# userIDFromNickName #userIDTo#infos# sendTime
    '''
    def __init__(self):
        Processor.__init__(self);
        self.__userIdFrom = 0;
        self.__userIdTo = 0;
        self.__infos = "";
        
    def dataValidtor(self, cmdContent):
        if not cmdContent:
            return False;
        paraLen = len(cmdContent);
        if paraLen == 3:      
            self.__userIdFrom = Func.strToInt(cmdContent[0], Config.I_SYS_ZERO);
            self.__userIdTo = Func.strToInt(cmdContent[1], Config.I_SYS_ZERO);
            self.__infos = Func.toStr(cmdContent[2]);            
            return True;        
        return False;
    def outData(self,):
        userFrom=UserDict.getUserFromUserDictById(self.__userIdFrom);
        if not userFrom:
            return None;
        userFromNickName=userFrom.get_user_nick_name();
        userTo=UserDict.getUserFromUserDictById(self.__userIdTo);
        if not userTo:
            return False;
        sendData=[self.__userIdFrom,userFromNickName,self.__userIdTo,self.__infos,Func.getNow()];        
        Func.sendMsgStr(userTo.get_socket(), self.setPackage(sendData));
        
        
        return True;            
        
             
